<% if pages.present? %>
<%= content_tag(
  'ul',
  :class => html_options[:class] || "navigation level_#{pages.first.level - 1}",
  :id => html_options[:id]
) do %>
  <% pages.each do |page| %>
    <% position = 'first' if page == pages.first %>
    <% position = 'last' if page == pages.last %>
    <%= content_tag(
      'li',
      :class => [page.slug, position, page_active?(page) ? 'active' : nil].compact.join(' ')
    ) do %>
      <%= render options[:navigation_link_partial], :page => page, :options => options %>
      <% options[:from_page] = page %>
      <% if options[:reverse_children] %>
        <% options[:reverse] = true %>
      <% end %>
      <% if options[:show_nonactive] %>
      <%= render_navigation(options) if options[:submenu] %>
      <% else %>
      <%= render_navigation(options) if (options[:submenu] && page_active?(page)) || options[:all_sub_menues] %>
      <% end %>
    <% end %>
    <% if options[:spacer].present? && position != 'last' %>
      <%= content_tag :li, options[:spacer].html_safe, class: 'navigation_spacer' %>
    <% end %>
  <% end %>
<% end %>
<% end %>
